package com.moma.chatting.dao;

import java.util.ArrayList;
import java.util.List;

import org.mybatis.spring.support.SqlSessionDaoSupport;

public class ChattingHistoryItemDao extends SqlSessionDaoSupport implements ChattingHistoryItemDaoMapper {
	public ChattingHistoryItem selectById(int id){
		ChattingHistoryItem item = (ChattingHistoryItem)getSqlSession()
				.selectOne("com.moma.chatting.dao.ChattingHistoryItemDaoMapper.selectById", id);
		return item;
	}

	public List<ChattingHistoryItem> selectByConversationId(int conversationId) {
		List<ChattingHistoryItem> items = new ArrayList<ChattingHistoryItem>();
		items = getSqlSession().selectList("selectByConversationId", conversationId);
		return items;
	}

	public List<ChattingHistoryItem> selectBySender(String senderUniqueName){
		List<ChattingHistoryItem> items = new ArrayList<ChattingHistoryItem>();
		items = getSqlSession().selectList("selectBySender", senderUniqueName);
		return items;
	}
	
	public void insertBatch(List<ChattingHistoryItem> items){
		getSqlSession().insert("insertBatch", items);
	}
	
	public void insert(ChattingHistoryItem item) {
		getSqlSession().insert("insert", item);
	}

	public void delete(int id){
		getSqlSession().delete("delete", id);
	}

	public void deleteByConversationId(int conversationId) {
		getSqlSession().delete("deleteByConversationId", conversationId);
	}
	
	public void deleteBySender(String senderUniqueName){
		getSqlSession().delete("deleteBySender", senderUniqueName);
	}
}
